<template>
    <div class="easyd-weixin-Box">

        <div class="search_box" v-if="$userData.getIsManager() == '1' && $userData.getUID()==1">
            <div class="app_box_flex app_list_box app_box_content_list C2 T3">
                <div class="app_box_content_left">加入知识库审核</div>
                <div class="app_box_content_right" @click="repositoryList()">
                    <span class="T3 C4">你有{{feedbackData.waitingSaveAsKnowledgeCount}}个审核</span>
                    <span class="fa fa-angle-right fa-lg C2"></span>
                </div>
            </div>
            <div class="app_box_flex app_list_box app_box_content_list C2 T3">
                <div class="app_box_content_left">回答反馈的问题</div>
                <div class="app_box_content_right" @click="objectionFeedbackList()">
                    <span class="T3 C4">你有{{feedbackData.waitingDealFeedbackCount}}个问题</span>
                    <span class="fa fa-angle-right fa-lg C2"></span>
                </div>
            </div>
        </div>
        <div class="search_box" v-else="$userData.getIsManager() == '1'">
            <div class="app_box_flex app_list_box app_box_content_list C2 T3">
                <div class="app_box_content_left">反馈问题</div>
                <div class="app_box_content_right" @click="objectionFeedbackList()">
                    <span class="T3 C4">有{{feedbackData.waitingDealFeedbackCount}}个反馈待处理</span>
                    <span class="fa fa-angle-right fa-lg C2"></span>
                </div>
            </div>
        </div>
        <div class="app_page_box" style="bottom:50px;" :style="$userData.getUID()==1 ? 'top: 95px;' : $userData.getIsManager() == '1' ? 'top: 50px;' : ''">
            <div class="app_page" :style="$userData.getIsManager() == '1' ? 'padding-top: 0;' : ''">
                <div class="objection_list app_box_content_list app_list_box MARGIN_BOTTOM_10" v-for="item in feedbackData.salesQuestion"
                     @click="lookObjection(item)">
                    <div class="objection_info">
                        <div class="app_box_flex MARGIN_BOTTOM_5">
                            <div class="app_box_content_left app_box_flex_5">
                                {{item.sq_content}}
                            </div>
                            <div class="app_box_content_right" style="color: #00ff1e;">
                                <span class="T2" v-if="item.sq_status>0" style="color: #999999">已处理</span>
                                <span class="T2" v-else style="color: #3aff56">待解决</span>
                            </div>
                        </div>

                        <ul class="MARGIN_BOTTOM_5" >
                            <li class=" T4 C4" v-for="textItem in item.new_sq_reply" v-if="textItem.type == '0'" v-html="textItem.txt"></li>
                        </ul>

                    </div>
                    <div class="objection_time C2 T3">
                        <span class="app_float_left">反馈时间：{{$common.getTimes(item.sq_create_time,'cn')}}</span>
                        <span class="app_float_right">{{feedbackTypeArr[item.sq_type]}}</span>
                    </div>
                </div>
            </div>
        </div>
        <div class="app_bottom_box">
            <div class="app_bottom_box_right" @click="myObjection()">我要反馈</div>
        </div>

    </div>
</template>

<script>
    import {mapState, mapMutations} from "vuex";

    export default {

        data() {
            return {
                feedbackTypeArr: ['行业知识', '产品知识', '销售技巧'], //反馈类型
            };
        },
        computed: {
            ...mapState({
                feedbackData: state => state.ObjectionListModule.feedbackData,
                tempSellAll: state => state.HomeModule.tempSellAll,
            }),
        },
        mounted() {
            this.initData()

            console.log('-=-----------------')
            console.log(this.tempSellAll)

        },
        methods: {

            //  ...mapMutations(["ShopIndexModule/updateIsShopGuide"]),

            initData() {

                var uids = this.$userData.getUID();
                if (this.tempSell) {
                    uids = this.tempSell;
                }
                
                //是否是超管
//              var isRoot = "/is_manager/" + this.$userData.getIsManager()
//                      + "/u_type/" + this.$userData.getOsType()
//                      + "/u_osid/" + this.$userData.getOsid()
                        
                         
            	var isRoot = '';   
                if (this.tempSellAll.u_master_osid != undefined && this.tempSellAll.u_master_osid != null && this.tempSellAll.u_master_osid != '') {
                	isRoot = ''
                    + "/u_id/" + this.tempSellAll.u_id
                    + "/u_osid/" + this.tempSellAll.u_master_osid
                    + "/is_manager/" + this.tempSellAll.u_is_manager 
                    + "/u_type/" + this.tempSellAll.u_type 
                    + "/u_leader/" + this.tempSellAll.u_leader;
            	}else{
            		isRoot = ''
                    + "/u_id/" + this.$userData.getUID()
                    + "/u_osid/" + this.$userData.getOsid()
                    + "/is_manager/" + this.$userData.getIsManager() 
                    + "/u_type/" + this.$userData.getOsType() 
                    + "/u_leader/" + this.$userData.getLeader();
            	}


                var aipUrl = '';
                aipUrl = this.$API.disputeProcessingList + isRoot;

                this.$easyUtil.startLoading(this)
                this.$http.getHttp(
                    aipUrl,
                    rs => {

                        console.log(rs)

                        for(var i=0;i<rs.salesQuestion.length;i++){
                            rs.salesQuestion[i].new_sq_reply = JSON.parse(rs.salesQuestion[i].sq_reply);
                        }

                        this.$store.commit("ObjectionListModule/updateFeedbackData", rs);

                        this.$easyUtil.endLoading(this)

                    }
                );
            },

            //我要反馈
            myObjection() {
                this.$router.push({
                    path: '/myObjection'
                })
            },

            //反馈问题列表
            objectionFeedbackList(item) {
                this.$router.push({
                    path: '/objectionFeedbackList'
                })
            },


            //知识库列表
            repositoryList(item) {
                this.$router.push({
                    path: '/repositoryList'
                })
            },

            //查看反馈问题
            lookObjection(item) {
                this.$easyUtil.GO(this, '/lookObjection', {sq_id: item.sq_id})
            },
        }
    };
</script>

<style lang="stylus" scoped>
    @import '~PUBLIC_CSS';
    .objection_list {
        overflow: hidden;
        line-height: 22px;
    }

    .objection_list .objection_info {
        float: initial;
    }

    .objection_list .objection_info ul {
        line-height: 20px;
        list-style: none;
    }

    .objection_list .objection_info ul li {
    }

    .objection_list .objection_time {
        overflow: hidden;
        width: 100%;
    }

    .objection_list .objection_time .app_float_right {
        color: #fbd415;
    }
</style>